import { fileURLToPath, URL } from 'node:url'

import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), UnoCSS()],
  base: './',
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      $: fileURLToPath(new URL('./src/scripts', import.meta.url))
    }
  },
  server: {
    proxy: {
      '/api/v1': {
        target: 'http://127.0.0.1:17020',
        changeOrigin: true
      },
      '/admin/api/v1': {
        target: 'http://127.0.0.1:17020',
        changeOrigin: true
      },
      '/user/api/v1': {
        target: 'http://127.0.0.1:17020',
        changeOrigin: true
      },
      '/copilot/api/v1': {
        target: 'http://127.0.0.1:17020',
        changeOrigin: true
      },
      '/imgs': {
        target: 'http://127.0.0.1:17020',
        changeOrigin: true
      }
    }
  },
  preview: {
    // custom your server host
    // host: '0.0.0.0',
    // custom your preview port
    // port: 17021
  }
})
